package com.joolun.mall.util.excel;

import com.alibaba.excel.write.style.row.AbstractRowHeightStyleStrategy;
import org.apache.poi.ss.usermodel.Row;

public class CustomRowHeightStyleStrategy extends AbstractRowHeightStyleStrategy {
    private final int targetRowIndex; // 目标行索引
    private final float rowHeight;    // 目标行高（单位：磅）

    public CustomRowHeightStyleStrategy(int targetRowIndex, float rowHeight) {
        this.targetRowIndex = targetRowIndex;
        this.rowHeight = rowHeight;
    }

    @Override
    protected void setHeadColumnHeight(Row row, int relativeRowIndex) {
        // 表头行：若匹配目标索引则设置行高
        if (relativeRowIndex == targetRowIndex) {
            row.setHeightInPoints(rowHeight);
        }
    }

    @Override
    protected void setContentColumnHeight(Row row, int relativeRowIndex) {
        // 内容行：若匹配目标索引则设置行高
        if (relativeRowIndex == targetRowIndex) {
            row.setHeightInPoints(rowHeight);
        }
    }
}